#include "Blocks/SpikedPlankBlock.h"

namespace PocketSurvival
{
	bool SpikedPlankBlock::isFaceTransparent(int32_t face, int32_t value)
	{
		int32_t mountingFace = GetMountingFace(Terrain::ExtractData(value));
		return face != CellFace::OppositeFace(mountingFace);
	}

    BlockPlacementData SpikedPlankBlock::getPlacementValue(ComponentMiner *componentMiner, int32_t value, const TerrainRaycastResult &raycastResult)
    {
		int32_t data = SetMountingFace(SetSpikesState(Terrain::ExtractData(value), true), raycastResult.cellFace.face);
		BlockPlacementData result;
		result.value = Terrain::ReplaceData(value, data);
		result.cellFace = raycastResult.cellFace;
		return result;
    }

    const std::vector<BoundingBox> &SpikedPlankBlock::getCustomCollisionBoxes(int32_t value)
    {
		int32_t num = Terrain::ExtractData(value);
		if (num < GET_ARRAY_LEN(BlockConstans::spikedPlankCollisionBoxes))
		{
			return BlockConstans::spikedPlankCollisionBoxes[num];
		}
		return Block::getCustomCollisionBoxes(value);
    }

	bool SpikedPlankBlock::shouldAvoid(int32_t value)
	{
		return GetSpikesState(Terrain::ExtractData(value));
	}
    int32_t SpikedPlankBlock::getIndex()
    {
        return Index();
    }
    const std::string &SpikedPlankBlock::getBlockName()
    {
        static std::string blockName = "SpikedPlankBlock";
        return blockName;
    }

} // namespace PocketSurvival
